home *** CD-ROM | disk | FTP | other *** search
/ Delphi Magazine Collection 2001 / Delphi Magazine Collection 20001 (2001).iso / DISKS / Issue48 / Clinic / MonWndU.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-05-19  |  1.4 KB  |  57 lines

  1. unit MonWndU;
  2.  
  3. interface
  4.  
  5. uses
  6.   Forms, Messages, Windows;
  7.  
  8. type
  9.   THelperForm = class(TForm)
  10.   public
  11.     MonitorWnd: HWnd;
  12.     MonitorProcess,
  13.     MonitorLibProcess: THandle;
  14.     TraceValue: Integer;
  15.     procedure WndProc(var Msg: TMessage); override;
  16.   end;
  17.  
  18. var
  19.   HelperForm: THelperForm;
  20.  
  21. implementation
  22.  
  23. uses
  24.   MonHelpU, MonLibU;
  25.  
  26. procedure THelperForm.WndProc(var Msg: TMessage);
  27. begin
  28.   inherited;
  29.   //Monitor tells us its window handle
  30.   if Msg.Msg = wm_MonitorNotify then
  31.   begin
  32.     MonitorWnd := TWMMonitorNotify(Msg).Wnd;
  33.     GetWindowThreadProcessId(MonitorWnd, @MonitorProcess);
  34.     MonitorLibProcess := GetCurrentProcess;
  35.     TraceValue := TWMMonitorNotify(Msg).TraceValue;
  36.   end
  37.   else
  38.   //Monitor tells us to reset client trace flags
  39.   if Msg.Msg = wm_UpdateClients then
  40.   begin
  41.     //Don't bother, if this is the DLL loaded by the monitor
  42.     if HelperForm.MonitorProcess = HelperForm.MonitorLibProcess then
  43.       Exit;
  44.     TraceValue := TWMUpdateClients(Msg).TraceValue;
  45.     UpdateClients(TraceValue);
  46.   end
  47. end;
  48.  
  49. initialization
  50.   HelperForm := THelperForm.CreateNew(nil);
  51.   //Tell monitor the handle of this library form window
  52.   //The monitor will send a message back to let us know its window handle
  53.   SendMessage(HWnd_Broadcast, wm_ClientLibNotify, HelperForm.Handle, 0);
  54. finalization
  55.   HelperForm.Free
  56. end.
  57.